home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_A / PROCESSO.{1E < prev    next >
Text File  |  1999-09-17  |  7KB  |  227 lines

  1. /* $Id: processor.h,v 1.53 1999/01/19 07:57:51 davem Exp $
  2.  * include/asm-sparc64/processor.h
  3.  *
  4.  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  5.  */
  6.  
  7. #ifndef __ASM_SPARC64_PROCESSOR_H
  8. #define __ASM_SPARC64_PROCESSOR_H
  9.  
  10. #include <asm/asi.h>
  11. #include <asm/a.out.h>
  12. #include <asm/pstate.h>
  13. #include <asm/ptrace.h>
  14. #include <asm/signal.h>
  15. #include <asm/segment.h>
  16.  
  17. /* Bus types */
  18. #define EISA_bus 0
  19. #define EISA_bus__is_a_macro /* for versions in ksyms.c */
  20. #define MCA_bus 0
  21. #define MCA_bus__is_a_macro /* for versions in ksyms.c */
  22.  
  23. /* The sparc has no problems with write protection */
  24. #define wp_works_ok 1
  25. #define wp_works_ok__is_a_macro /* for versions in ksyms.c */
  26.  
  27. /* User lives in his very own context, and cannot reference us. */
  28. #ifndef __ASSEMBLY__
  29. #define TASK_SIZE    ((unsigned long)-PGDIR_SIZE)
  30. #else
  31. #define TASK_SIZE    0xfffffffc00000000
  32. #endif
  33.  
  34. #ifndef __ASSEMBLY__
  35.  
  36. #define NSWINS        7
  37.  
  38. typedef struct {
  39.     unsigned long seg;
  40. } mm_segment_t;
  41.  
  42. /* The Sparc processor specific thread struct. */
  43. struct thread_struct {
  44. /*DC1*/    unsigned long ksp __attribute__ ((aligned(16)));
  45.     unsigned short wstate;
  46.     unsigned short cwp;
  47.     unsigned short flags;
  48.     unsigned short ctx;
  49.  
  50. /*DC2*/    unsigned short w_saved;
  51.     unsigned short new_signal;
  52.     unsigned int ___pad;
  53.     mm_segment_t current_ds;
  54.  
  55. /*DC3*/    struct pt_regs *kregs;
  56.     unsigned long *utraps;
  57.  
  58.     struct reg_window reg_window[NSWINS] __attribute__ ((aligned (16)));
  59.     unsigned long rwbuf_stkptrs[NSWINS] __attribute__ ((aligned (8)));
  60.     
  61.     unsigned long sig_address __attribute__ ((aligned (8)));
  62.     unsigned long sig_desc;
  63.     
  64.     /* Performance counter state */
  65.     u64 *user_cntd0, *user_cntd1;
  66.     u64 kernel_cntd0, kernel_cntd1;
  67.     u64 pcr_reg;
  68.  
  69.     unsigned char fpdepth;
  70.     unsigned char fpsaved[7];
  71.     unsigned char gsr[7];
  72.     unsigned long xfsr[7];
  73. };
  74.  
  75. #endif /* !(__ASSEMBLY__) */
  76.  
  77. #define SPARC_FLAG_KTHREAD      0x010    /* task is a kernel thread */
  78. #define SPARC_FLAG_UNALIGNED    0x020    /* is allowed to do unaligned accesses */
  79. #define SPARC_FLAG_NEWSIGNALS   0x040    /* task wants new-style signals */
  80. #define SPARC_FLAG_32BIT        0x080    /* task is older 32-bit binary */
  81. #define SPARC_FLAG_NEWCHILD     0x100    /* task is just-spawned child process */
  82. #define SPARC_FLAG_PERFCTR    0x200    /* task has performance counters active */
  83.  
  84. #define INIT_MMAP { &init_mm, 0xfffff80000000000, 0xfffff80001000000, \
  85.             NULL, PAGE_SHARED , VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
  86.  
  87. #define INIT_TSS  {                        \
  88. /* ksp, wstate, cwp, flags,              ctx, */         \
  89.    0,   0,      0,   SPARC_FLAG_KTHREAD, 0,            \
  90. /* w_saved, new_signal, padding, current_ds, */            \
  91.    0,       0,          0,       KERNEL_DS,            \
  92. /* kregs,   utraps, */                        \
  93.    0,       0,                            \
  94. /* reg_window */                        \
  95.    { { { 0, }, { 0, } }, },                     \
  96. /* rwbuf_stkptrs */                        \
  97.    { 0, 0, 0, 0, 0, 0, 0, },                    \
  98. /* sig_address, sig_desc */                    \
  99.    0,           0,                        \
  100. /* user_cntd0, user_cndd1, kernel_cntd0, kernel_cntd0, pcr_reg */ \
  101.    0,          0,          0,         0,            0,    \
  102. /* fpdepth, fpsaved, gsr,   xfsr */                \
  103.    0,       { 0 },   { 0 }, { 0 },                \
  104. }
  105.  
  106. #ifndef __ASSEMBLY__
  107.  
  108. /* Return saved PC of a blocked thread. */
  109. extern __inline__ unsigned long thread_saved_pc(struct thread_struct *t)
  110. {
  111.     unsigned long *sp = (unsigned long *)(t->ksp + STACK_BIAS);
  112.     unsigned long *fp = (unsigned long *)(sp[14] + STACK_BIAS);
  113.  
  114.     return fp[15];
  115. }
  116.  
  117. /* On Uniprocessor, even in RMO processes see TSO semantics */
  118. #ifdef __SMP__
  119. #define TSTATE_INITIAL_MM    TSTATE_TSO
  120. #else
  121. #define TSTATE_INITIAL_MM    TSTATE_RMO
  122. #endif
  123.  
  124. /* Do necessary setup to start up a newly executed thread. */
  125. #define start_thread(regs, pc, sp) \
  126. do { \
  127.     regs->tstate = (regs->tstate & (TSTATE_CWP)) | (TSTATE_INITIAL_MM|TSTATE_IE) | (ASI_PNF << 24); \
  128.     regs->tpc = ((pc & (~3)) - 4); \
  129.     regs->tnpc = regs->tpc + 4; \
  130.     regs->y = 0; \
  131.     current->tss.flags &= ~SPARC_FLAG_32BIT; \
  132.     current->tss.wstate = (1 << 3); \
  133.     if (current->tss.utraps) { \
  134.         if (*(current->tss.utraps) < 2) \
  135.             kfree (current->tss.utraps); \
  136.         else \
  137.             (*(current->tss.utraps))--; \
  138.         current->tss.utraps = NULL; \
  139.     } \
  140.     __asm__ __volatile__( \
  141.     "stx        %%g0, [%0 + %2 + 0x00]\n\t" \
  142.     "stx        %%g0, [%0 + %2 + 0x08]\n\t" \
  143.     "stx        %%g0, [%0 + %2 + 0x10]\n\t" \
  144.     "stx        %%g0, [%0 + %2 + 0x18]\n\t" \
  145.     "stx        %%g0, [%0 + %2 + 0x20]\n\t" \
  146.     "stx        %%g0, [%0 + %2 + 0x28]\n\t" \
  147.     "stx        %%g0, [%0 + %2 + 0x30]\n\t" \
  148.     "stx        %%g0, [%0 + %2 + 0x38]\n\t" \
  149.     "stx        %%g0, [%0 + %2 + 0x40]\n\t" \
  150.     "stx        %%g0, [%0 + %2 + 0x48]\n\t" \
  151.     "stx        %%g0, [%0 + %2 + 0x50]\n\t" \
  152.     "stx        %%g0, [%0 + %2 + 0x58]\n\t" \
  153.     "stx        %%g0, [%0 + %2 + 0x60]\n\t" \
  154.     "stx        %%g0, [%0 + %2 + 0x68]\n\t" \
  155.     "stx        %1,   [%0 + %2 + 0x70]\n\t" \
  156.     "stx        %%g0, [%0 + %2 + 0x78]\n\t" \
  157.     "wrpr        %%g0, (1 << 3), %%wstate\n\t" \
  158.     : \
  159.     : "r" (regs), "r" (sp - REGWIN_SZ - STACK_BIAS), \
  160.       "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
  161. } while(0)
  162.  
  163. #define start_thread32(regs, pc, sp) \
  164. do { \
  165.     pc &= 0x00000000ffffffffUL; \
  166.     sp &= 0x00000000ffffffffUL; \
  167. \
  168.     regs->tstate = (regs->tstate & (TSTATE_CWP))|(TSTATE_INITIAL_MM|TSTATE_IE|TSTATE_AM); \
  169.     regs->tpc = ((pc & (~3)) - 4); \
  170.     regs->tnpc = regs->tpc + 4; \
  171.     regs->y = 0; \
  172.     current->tss.flags |= SPARC_FLAG_32BIT; \
  173.     current->tss.wstate = (2 << 3); \
  174.     if (current->tss.utraps) { \
  175.         if (*(current->tss.utraps) < 2) \
  176.             kfree (current->tss.utraps); \
  177.         else \
  178.             (*(current->tss.utraps))--; \
  179.         current->tss.utraps = NULL; \
  180.     } \
  181.     __asm__ __volatile__( \
  182.     "stxa        %3, [%4] %5\n\t" \
  183.     "stx        %%g0, [%0 + %2 + 0x00]\n\t" \
  184.     "stx        %%g0, [%0 + %2 + 0x08]\n\t" \
  185.     "stx        %%g0, [%0 + %2 + 0x10]\n\t" \
  186.     "stx        %%g0, [%0 + %2 + 0x18]\n\t" \
  187.     "stx        %%g0, [%0 + %2 + 0x20]\n\t" \
  188.     "stx        %%g0, [%0 + %2 + 0x28]\n\t" \
  189.     "stx        %%g0, [%0 + %2 + 0x30]\n\t" \
  190.     "stx        %%g0, [%0 + %2 + 0x38]\n\t" \
  191.     "stx        %%g0, [%0 + %2 + 0x40]\n\t" \
  192.     "stx        %%g0, [%0 + %2 + 0x48]\n\t" \
  193.     "stx        %%g0, [%0 + %2 + 0x50]\n\t" \
  194.     "stx        %%g0, [%0 + %2 + 0x58]\n\t" \
  195.     "stx        %%g0, [%0 + %2 + 0x60]\n\t" \
  196.     "stx        %%g0, [%0 + %2 + 0x68]\n\t" \
  197.     "stx        %1,   [%0 + %2 + 0x70]\n\t" \
  198.     "stx        %%g0, [%0 + %2 + 0x78]\n\t" \
  199.     "wrpr        %%g0, (2 << 3), %%wstate\n\t" \
  200.     : \
  201.     : "r" (regs), "r" (sp - REGWIN32_SZ), \
  202.       "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0])), \
  203.       "r" (((unsigned long)current->mm->pgd[0])<<11UL), \
  204.       "r" (TSB_REG), "i" (ASI_DMMU)); \
  205. } while(0)
  206.  
  207. /* Free all resources held by a thread. */
  208. #define release_thread(tsk)        do { } while(0)
  209.  
  210. #define copy_segments(nr, tsk, mm)    do { } while (0)
  211. #define release_segments(mm)        do { } while (0)
  212. #define forget_segments()        do { } while (0)
  213.  
  214. #ifdef __KERNEL__
  215. /* Allocation and freeing of task_struct and kernel stack. */
  216. #define alloc_task_struct()   ((struct task_struct *)__get_free_pages(GFP_KERNEL, 1))
  217. #define free_task_struct(tsk) free_pages((unsigned long)(tsk),1)
  218.  
  219. #define init_task    (init_task_union.task)
  220. #define init_stack    (init_task_union.stack)
  221.  
  222. #endif /* __KERNEL__ */
  223.  
  224. #endif /* !(__ASSEMBLY__) */
  225.  
  226. #endif /* !(__ASM_SPARC64_PROCESSOR_H) */
  227.